<?php
function countTable() {
	$tablelist=mysql_query("SHOW TABLES");
	$table = 0;

	while ($table < mysql_num_rows($tablelist))
	{
		//$tablename=mysql_tablename($tablelist, $table);
		//echo $tablename;
		$table++;
	}
	return ($table-4);
}

function numOfTable_Reservations($i,$status) {
	$today = date("Y-m-d H:i:s");

	if($status == 0) {
		//$result = mysql_query("SELECT * FROM table$i WHERE date_start LIKE '%$today%' AND status = '0'");
		$result = mysql_query("SELECT * FROM table$i WHERE date_start >= '$today' AND status = '0'");
		$num_row = mysql_num_rows($result);
		return  $num_row;
	} else {
		//$result = mysql_query("SELECT * FROM table$i WHERE date_start LIKE '%$today%' AND status = '1'");
		$result = mysql_query("SELECT * FROM table$i WHERE date_start >= '$today' AND status = '1'");
		$num_row = mysql_num_rows($result);
		return  $num_row;
	}
}

function count_allpeople() {
	$today = date("Y-m-d H:i:s");
	$tempC = 0;

	$result_p = mysql_query("SELECT * FROM reservation WHERE time_end > '$today'");
	$numP = mysql_num_rows($result_p);

	if($numP > 0) {
		header("charset=utf-8");
		$msg = "ปัจจุบันมีผู้จองโต๊ะอาหารจำนวนทั้งหมด&nbsp;$numP&nbsp;รายการ";
		return $msg;
	}else {
		header("charset=utf-8");
		$msg = "ปัจจุบันร้านอาหารของคุณยังไม่มีรายการจองโต๊ะอาหาร";
		return $msg;
	}

}

?>